<?php
        require_once('../inc/items.php');
        require_once('../inc/ShCar.php');
        require_once('../inc/logins.php');
        RequireLogin();
        $results = getCars();
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Database Access: Shopping Cart Info</title>
        <link type="text/css" rel="stylesheet" href="../inc/bootstrap.css" />
        <link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css" />
    </head>
   
    <body>
    	<div class="container">
    	<? include('../inc/header.php'); ?>
    	<? include('../inc/nav.php'); ?>
		<div id="contents">
		
		<? if(isset($_GET['inserted'])): ?>
                        <div class="alert alert-success">
                        <button class="close">×</button>
                        Record inserted succesfuly.
                    </div>
                <? endif; ?>
		
		<a href="edit.php" class="add-link">+ Add New Shopping Car</a>
		
		<form method="post" action="edit.php">
         <table class="table table-striped table-bordered table-condensed table-hover">
         		<thead>
                <tr>
                <th>Purchase ID</th><th>Item S/N</th><th>Item Quantity</th><th>Item Name</th><th>Actions</th>
            	</tr>
            	</thead>
            	
            	<tbody>
            <? while($rs = $results->fetch_assoc()):
            	$rs1 = getItem($rs['item_ID']);?>
                <tr class="<? if($rs['purchase_ID'] == $_GET['inserted'] AND $rs['item_ID'] == $_GET['item_ID']){ echo 'info';} else {echo '';}?>">
                    <td><?=$rs['purchase_ID']?></td>
                    <td><?=$rs1['serialNumber']?></td>
                    <td><?=$rs['quantity']?></td>
                    <td><?=$rs1['name']?></td>
                    <td>
                    	<!--<a href="details.php">Details</a>-->
						<a href="edit.php?purchase_ID=<?=$rs['purchase_ID']?>&item_ID=<?=$rs1['serialNumber']?>" class="edit-link">Edit</a>   
                    	<a href="delete.php?id=<?=$rs['purchase_ID']?>&item_ID=<?=$rs1['serialNumber']?>" class="delete-link">Delete</a>
                    </td>
                  </tr>
              <? endwhile; ?>
              </tbody>
        </table>
        </form>
        </div>
       </div>
       
       <div class="modal hide fade">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h3>Delete item From shopping cart</h3>
                </div>
                <div class="modal-body"></div>
            </div>

       <? include("../inc/jQueryStart.php")?>;
       
   </body>
</html>